<div class="section visible" id="status" data-status="{{ rdoc.status }}">
  <div class="section__header">
    <h1 class="section__title">
      <span class="icon record-status--icon {{ model.builtin.STATUS_CODES[rdoc['status']] }}"></span>
      {% if typeof(rdoc['score']) == 'number' %}
      <span style="color: {{ utils.status.getScoreColor(rdoc.score|default(0)) }}">{{ rdoc.score|default(0) }}</span>
      {% endif %}
      <span class="record-status--text {{ model.builtin.STATUS_CODES[rdoc['status']] }}">
        {{ model.builtin.STATUS_TEXTS[rdoc['status']] }}
      </span>
      {% if rdoc.progress %}{{ rdoc.progress|int }}%{% endif %}
    </h1>
  </div>
{% if rdoc.compilerTexts.length %}
  <div class="section__body">
    <pre class="compiler-text">{{ rdoc.compilerTexts|join('\n')|ansi|safe }}<div class="compiler-text-mask"><p><span class="icon icon-expand_more">{{ _('Expand') }}</span></p></div></pre>
  </div>
{% endif %}
{% if rdoc.judgeTexts.length %}
  <div class="section__body">
    <pre class="judge-text">{{ formatJudgeTexts(rdoc.judgeTexts)|ansi|safe }}</pre>
  </div>
{% endif %}
{% if rdoc.testCases.length %}
  <div class="section__body no-padding">
    <table class="data-table record_detail__table">
      <colgroup>
        <col class="col--case">
        <col class="col--status">
        <col class="col--time">
        <col class="col--memory">
      </colgroup>
      <thead>
        <tr>
          <th class="col--case record-status--border">#</th>
          <th class="col--status">
            {{ _('Status') }}
            {% if rdoc.subtasks and (rdoc.subtasks|length > 1 or rdoc.subtasks[Object.keys(rdoc.subtasks)[0]].type == 'sum') %}
            <span class="float-right">{{ _('Score') }}</span>
            {% endif %}
          </th>
          <th class="col--time">{{ _('Time Cost') }}</th>
          <th class="col--memory">{{ _('Memory Cost') }}</th>
        </tr>
      </thead>
      <tbody>
      {% set _key = 'id' if rdoc.testCases|groupby('subtaskId')|length == 1 else 'subtaskId' %}
      {%- for subtaskId, rcdocs in rdoc.testCases|sort(false,false,_key)|groupby(_key) -%}
        {% if rcdocs.length > 1 %}
        <tr class="subtask">
          <td class="col--case">
            #{{ subtaskId|int|default(1) }}
          </td>
          {% if rdoc.subtasks %}
          <td class="col--status">
            <span class="icon record-status--icon {{ model.builtin.STATUS_CODES[rdoc.subtasks[subtaskId]['status']] }}"></span>
            <span class="record-status--text {{ model.builtin.STATUS_CODES[rdoc.subtasks[subtaskId]['status']] }}">
              {{ model.builtin.STATUS_TEXTS[rdoc.subtasks[subtaskId]['status']] }}
            </span>
            <span class="float-right record-status--text {{ model.builtin.STATUS_CODES[rdoc.subtasks[subtaskId]['status']] }}">{{ rdoc.subtasks[subtaskId]['score']|default(0) }}</span>
          </td>
          <td class="col--time"></td>
          <td class="col--memory"></td>
          {% endif %}
        </tr>
        {% endif %}
        {%- for rcdoc in rcdocs|sort(false,false,'id') -%}
          <tr class="{{ 'subtask-case' if rcdocs.length == 1 else 'case' }}">
            <td class="col--case record-status--border {{ model.builtin.STATUS_CODES[rcdoc['status']] }}">
              #{{ subtaskId|int|default(1) }}{% if rcdocs.length > 1 %}-{{ rcdoc.id|default(loop.index) }}{% endif %}
            </td>
            <td class="col--status">
              <span class="icon record-status--icon {{ model.builtin.STATUS_CODES[rcdoc['status']] }}"></span>
              <span class="record-status--text {{ model.builtin.STATUS_CODES[rcdoc['status']] }}">
                {{ model.builtin.STATUS_TEXTS[rcdoc['status']] }}
              </span>
              {% if (rdoc.subtasks and _key != 'id' and rcdocs.length == 1) or (_key == 'id' and rdoc.subtasks[rcdoc.subtaskId].type == 'sum') %}
              <span class="float-right record-status--text {{ model.builtin.STATUS_CODES[(rdoc.subtasks[subtaskId]['status'] if _key != 'id' else rcdoc.status)] }}">
                {{ (rdoc.subtasks[subtaskId]['score'] if _key != 'id' else rcdoc.score)|default(0) }}
              </span>
              {% endif %}
              <span class="message">{{ formatJudgeTexts([rcdoc.message])|ansi|safe if rcdoc.message else '' }}</span>
            </td>
            <td class="col--time">{% if rcdoc['status'] == STATUS.STATUS_TIME_LIMIT_EXCEEDED or rcdoc['status'] == STATUS.STATUS_MEMORY_LIMIT_EXCEEDED or rcdoc['status'] == STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED %}&ge;{% endif %}{{ rcdoc.time|round|int }}ms</td>
            <td class="col--memory">{% if rcdoc['status'] == STATUS.STATUS_TIME_LIMIT_EXCEEDED or rcdoc['status'] == STATUS.STATUS_MEMORY_LIMIT_EXCEEDED or rcdoc['status'] == STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED %}&ge;{% endif %}{{ size(rcdoc.memory, 1024) }}</td>
          </tr>
        {%- endfor -%}
      {%- endfor -%}
      </tbody>
    </table>
  </div>
{% endif %}
</div>
